import http from '../../util/request.js';
var page = 1;
var pageSize = 20;
var app = getApp();

var GetList = function (that) {
  if (that.data.hidden) {
    that.setData({
      hidden: false
    });
    http.get('tips', {
      act: 'userLike',
      page: page,
      pageSize: pageSize
    }).then(function (res) {
      var list = that.data.list;
      if (res.length > 0) {
        for (var i = 0; i < res.length; i++) {
          list.push(res[i]);
        }
        that.setData({
          list: list
        });
        page++;
        that.setData({
          hidden: true
        });
      } else {
        that.setData({
          load_text: '没有更多数据'
        });
      }
    });
  }
}
Page({
  data: {
    hidden: true,
    list: [],
    scrollTop: 0,
    scrollHeight: 0,
    load_text: '加载中...'
  },
  onLoad: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        console.info(res.windowHeight);
        that.setData({
          scrollHeight: res.windowHeight
        });
      }
    });
  },
  onShow: function () {
    var that = this;
    page = 1;
    GetList(that);
  },
  bindDownLoad: function () {
    var that = this;
    GetList(that);
  }
})